<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>

<body>
    <div id="app">
        <input type="button" value="浪起来" @click="fn">
        <input type="button" value="停止" @click="fn1">

        <h3>{{ msg }}</h3>
    </div>

    <script>
        var vm = new Vue({
            data: {
                msg: '我拿Buff,谢谢~',
                intervalId: null
            },
            methods: {
                fn() {
                    if (this.intervalId !== null) return
                     this.intervalId = setInterval(() => {
                        const h = this.msg.slice(0, 1)
                        const m = this.msg.slice(1)
                        this.msg = m + h
                    }, 1000)
                      },
                fn1() {
                    clearInterval(intervalId)
                    this.intervalId = null
                }

            }
        }).$mount('#app')
    </script>
</body>

</html>